package com.yanqu.file;

/**
 * 不改名，老引用不到
 */
public class FileConfig {

    String logDirectory;
    RotateMode rotateMode = RotateMode.DAILY;
    String lockFileName;
    String fileNamePrefix;
    int interval = 0;
    int fileSize = 0;
    int bufferSize = 8192;
    boolean autoFlush = false;

    /**
     * 创建指定日志存放路径的 LoggerConsumer 配置
     *
     * @param logDirectory 日志存放路径
     */
    public FileConfig(String logDirectory) {
        this(logDirectory, 0);
    }

    /**
     * 创建指定日志存放路径和日志大小的 LoggerConsumer 配置
     *
     * @param logDirectory 日志存放路径
     * @param fileSize     日志大小, 单位 MB, 默认为无限大
     */
    public FileConfig(String logDirectory, int fileSize) {
        this.logDirectory = logDirectory;
        this.fileSize = fileSize;
    }

    /**
     * 设置日志切分模式
     *
     * @param rotateMode 日志切分模式
     */
    public void setRotateMode(RotateMode rotateMode) {
        this.rotateMode = rotateMode;
    }

    /**
     * 设置日志大小
     *
     * @param fileSize 日志大小，单位 MB
     */
    public void setFileSize(int fileSize) {
        this.fileSize = fileSize;
    }

    public void setLockFile(String lockFileName) {
        this.lockFileName = lockFileName;
    }

    /**
     * 设置缓冲区容量, 当超过该容量时会触发 flush 动作
     *
     * @param bufferSize 缓冲区大小，单位 byte.
     */
    public void setBufferSize(int bufferSize) {
        this.bufferSize = bufferSize;
    }

    /**
     * 设置用户名前缀
     *
     * @param fileNamePrefix
     */
    public void setFilenamePrefix(String fileNamePrefix) {
        this.fileNamePrefix = fileNamePrefix;
    }

    /**
     * 设置自动保存
     *
     * @param autoFlush
     */
    public void setAutoFlush(boolean autoFlush) {
        this.autoFlush = autoFlush;
    }

    /**
     * 自动保存间隔
     *
     * @param interval
     */
    public void setInterval(int interval) {
        this.interval = interval;
    }
}